home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Supra Voice&Fax1&ARA < prev    next >
Text File  |  1994-04-11  |  10KB  |  582 lines

  1. !V2.2.10
  2. !
  3. !$ Use this script with Supra 14400bps and 9600bps fax modems.
  4. !$ Supports: voice, fax, and ARA incoming calls.
  5. !
  6. !$ Make sure that *Class 1* fax software is installed, and that
  7. !$ your modem has voice-capable ROMs.
  8. !
  9. !$ A hardware handshaking cable is required.
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1","Always"="2") "1"
  12. ^3 Speaker Volume:   = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^6 Handshake wires:   = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @HANGUP
  19.   SerReset 19200,0,8,1
  20.   HsReset 0,0,17,19,0,0
  21.   Flush
  22.   SetTries 2
  23.   write "ATH0S0=0\r"
  24.   Flush
  25.  
  26. !
  27. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  28. ! to enter the command mode
  29. !
  30. @Label 1
  31.   write "AT+VC=0\r"
  32.   flush
  33.   write "AT&F1\r"
  34.   matchclr
  35.   matchstr 1 2 "OK\r\n"
  36.   matchread 20
  37. !  chrdelay 1
  38.   Write "+++"
  39. !  chrdelay 0
  40.   DtrClear
  41.   LBreak
  42.   DtrSet
  43.  
  44.   write "AT+VC=0\r"
  45.   matchclr
  46.   matchstr 1 1 "OK\r\n"
  47.   matchread 10
  48. !
  49.   write "ATE0V1\r"
  50.   matchstr 1 1 "OK\r\n"
  51.   matchread 10
  52.  
  53.   write "ATH0\r"
  54.   matchstr 1 1 "OK\r\n"
  55.   matchread 10
  56.   DecTries
  57.   IfTries 0 1
  58.   exit -6019
  59.  
  60. @Label 2
  61.   SerReset 19200,0,8,1
  62.   Jsr 80
  63.   Write "AT+FCLASS=0\r"
  64.   Jsr 100
  65.   Write "AT+FAE=0\r"
  66.   Jsr 100
  67.   exit 0
  68.  
  69.  
  70. ! ------------------------------------------
  71. !    Receiving incoming calls
  72. ! ------------------------------------------
  73. @ANSWER
  74. !
  75. ! Set the modem preferred speed first
  76. !
  77.    SerReset 19200,0,8,1
  78.   Jsr 80
  79.   Jsr 70
  80.  
  81. @Label 3
  82.   ifOpen "Voice" 4
  83.   Jump 47
  84.  
  85. ! check to see if the voice code has been downloaded
  86. ! if not, tell PhonePro to download it.
  87. !
  88. @Label 4
  89.   Note "Checking the modem..."
  90.   Write "AT+VC=0\r"
  91.   MatchClr
  92.   MatchStr 1 5 "OK\r\n"
  93.   MatchStr 2 5 "ERROR\r\n"
  94.   MatchRead 10
  95.   Exit -6019
  96.  
  97. @Label 5
  98.   Write "AT+VC=1\r"
  99.   MatchClr
  100.   MatchStr 1 7 "OK\r\n"
  101.   MatchStr 2 6 "ERROR\r\n"
  102.   MatchRead 20
  103.   Exit -6019
  104. !
  105. !  tell the Voice Tool to download the voice code
  106. !
  107. @Label 6
  108.   Note "Downloading voice code to modem..."
  109.   Pause 20
  110.   QueueInput "\r\nLOAD\r\n"
  111.   Attach "Voice" (Master)
  112.  
  113. @Label 7
  114.   Write "AT+VC=0\r"
  115.   Jsr 100
  116.  
  117. !
  118. ! sit and wait for a call for up to 30 seconds, then re-initiate the modem
  119. !
  120. !@Label 8
  121. !
  122. ! Get caller ID, if voice enabled
  123.   QueueInput "\r\nGET_CALLER_ID_FLAG\r\n"
  124.   Attach "Voice" (Master)
  125.   SetVar B "^$"
  126.   Write "AT#CID=^B\r"
  127.   Jsr 100
  128.  
  129.   Note "Waiting for a Voice/Fax/ARA call"
  130.   MatchClr
  131.   MatchStr 1 15 "RING\r\n"
  132.   MatchRead 1800
  133.   Jump 3
  134.  
  135. @Label 15
  136.   Note "Ring..."
  137.   QueueInput "\r\nRING\r\n"
  138.   Attach "Voice" (Master)
  139.   Write "+++"
  140.   Note "Switching from voice..."
  141.  
  142. ! fall through if the call is not a voice call (as indicated by the telephone tool)
  143. !
  144.   SetVar A "^$"
  145.   SerReset 19200,0,8,1
  146. !  Jsr 80
  147.   HsReset 0,0,17,19,0,0
  148. !  Write "\r\r\r"
  149. !  Pause 10
  150.   Jsr 80
  151.  
  152. !  Write "ATV1E0\r"
  153. !  Jsr 100
  154.  
  155. !  Pause 2
  156. !  Write "AT&F\r"
  157. !  Jsr 100
  158.  
  159. !  Jsr 70
  160.  
  161.   IfStr A 17 "Fax"
  162.   IfStr A 18 "ARA"
  163.   Exit -6019
  164.  
  165. !
  166. ! Force to answer a Fax call
  167. !
  168. @Label 17
  169.   Note "Switching to Fax..."
  170.   Write "AT+FCLASS=1;+FAE=0\r"
  171.   Jsr 100
  172.   Write "AT&K4E0V0A\r"
  173.   MatchClr
  174.   MatchStr 1 30 "1\r"
  175.   MatchStr 2 93 "3\r"
  176.   MatchStr 3 94 "8\r"
  177.   MatchRead 300
  178.   Write "\r"
  179.   Exit -6019
  180.  
  181. !
  182. ! Force to answer an ARA call
  183. !
  184. @Label 18
  185.   Note "Switching to ARA..."
  186.   Jsr 70
  187. ! Set the communication options:
  188.   Jsr 55
  189.  
  190.   Write "AT+FAE=0;+FCLASS=0\r"
  191.   Jsr 100
  192.   Write "ATA\r"
  193.   MatchClr
  194.   MatchStr 1 20 "\r\nCARRIER "
  195.   MatchStr 4 93 "NO CARRIER\r\n"
  196.   MatchStr 5 94 "NO ANSWER\r\n"
  197.   MatchRead 300
  198.   Write "\r"
  199.   Exit -6019
  200.  
  201. @Label 20
  202.   QueueInput "\r\nCARRIER "
  203.   ifOriginate 21
  204.   QueueInput "\r\nRING\r\n"
  205. @Label 21
  206.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  207.  
  208. !
  209. ! Fax connection has been established (we read "1\r")
  210. ! Attach the "Fax" subPort
  211. !
  212. @Label 30
  213.  
  214.   QueueInput "1\r"
  215.   ifOriginate 32
  216. @Label 31
  217.   QueueInput "2\r"
  218. @Label 32
  219.   Attach "Fax" (DTR,Reset)
  220.  
  221. !
  222. ! Converting numeric responses into verbal
  223. !
  224. @Label 40
  225.   QueueInput "2400\r\n"
  226.   Jump 20
  227. @Label 41
  228.   QueueInput "4800\r\n"
  229.   Jump 20
  230. @Label 42
  231.   QueueInput "7200\r\n"
  232.   Jump 20
  233. @Label 43
  234.   QueueInput "9600\r\n"
  235.   Jump 20
  236. @Label 44
  237.   QueueInput "12000\r\n"
  238.   Jump 20
  239. @Label 45
  240.   QueueInput "14400\r\n"
  241.   Jump 20
  242.  
  243. !
  244. ! Waiting for Fax/ARA calls only (no Voice App running)
  245. !
  246. @Label 47
  247.   Note "Voice Application is not running..."
  248.   Jsr 55
  249.  
  250. !  No Voice App running -- turn off caller ID
  251.   Write "AT#CID=0\r"
  252.   Jsr 100
  253.  
  254. !  This would allow us to not go into AA mode if we could have more labels.
  255.   ifOpen "ARA" 49
  256.   ifOpen "Fax" 49
  257.   Jump 160
  258. !
  259. !
  260. ! Set Fax mode
  261. !
  262. @Label 49
  263.   Write "AT\\N0&Q6&K3W1\r"
  264.   Jsr 100
  265.   Write "AT+FCLASS=1\r"
  266.   Jsr 100
  267.   Write "AT+FAE=1\r"
  268.   Jsr 100
  269.   Write "AT+FCLASS=0\r"
  270.   Jsr 100
  271. !
  272. ! Tell the modem to determine the type of the incoming call
  273. ! Fetch the tube after ^4 rings
  274. !
  275.  Write "ATS0=^4V0\r"
  276.   Jsr 110
  277. !
  278. ! Everything is ready - let's sit and wait for a call
  279. ! We'll wait for 30 seconds, then reinitiate the modem
  280. !
  281.   Note "Waiting for a fax or ARA call..."
  282.   MatchClr
  283.   matchstr 02 40 "47\r"
  284.   MatchStr 03 41 "48\r"
  285.   MatchStr 04 42 "49\r"
  286.   MatchStr 05 43 "50\r"
  287.   MatchStr 06 44 "51\r"
  288.   MatchStr 07 45 "52\r"
  289.   MatchStr 09 31 "33\r"
  290.   matchstr 10 53 "2\r"
  291.   matchstr 12 30 "1\r"
  292.   matchstr 13 52 "3\r"
  293.   matchstr 14 52 "8\r"
  294.   matchstr 15 52 "7\r"
  295. @Label 51
  296.   Matchread 600
  297. @Label 52
  298.   Write "ATV1\r"
  299.   Jsr 100
  300.   Jump 3
  301. @Label 53
  302.   Note "Ring..."
  303.   Jump 51
  304.  
  305. ! ------------------------------------------
  306. ! Originating a call through the "Voice" subport
  307. ! ------------------------------------------
  308. @ORIGINATE "Voice" ("\r\nBusy\r\n")
  309.   Note "PhonePro is originating a call ..."
  310.   SerReset *
  311.   HsReset *
  312.   Attach "Voice" (Escape, Master)
  313.   Exit -6019
  314.  
  315.  
  316.  
  317. ! ------------------------------------------
  318. ! Originating a call through the "ARA" subport
  319. ! ------------------------------------------
  320. @ORIGINATE "ARA" ("\r\nBusy\r\n")
  321.   SerReset *
  322.   HsReset *
  323.   Jsr 80
  324. !
  325. ! Set the common options
  326. !
  327.   Jsr 70
  328.   Jsr 55
  329. !
  330. ! Prepare to receive all error result codes, dial the number
  331. !
  332.   Jsr 90
  333.   MatchStr 1 20 "\r\nCARRIER "
  334.   MatchRead 1000
  335.   Write "\r"
  336.   Exit -6019
  337.  
  338. ! ------------------------------------------
  339. ! Originating a call through the "Fax" subPort
  340. ! ------------------------------------------
  341. @ORIGINATE "Fax" ("\r\nBUSY\r\n")
  342. ! Clear the modem's magic memory
  343.   Jsr 130
  344. !
  345. ! Set the "Fax" speed
  346. !
  347.   SerReset *
  348.   HsReset *
  349.   Jsr 80
  350.   Write "ATZ\r"
  351.   Jsr 100
  352.  
  353.   Write "AT+VC=0\r"
  354.   Jsr 120
  355.  
  356.  
  357. !
  358. ! Set the common options
  359. !
  360.   Jsr 70
  361. !
  362. ! Set the Fax mode
  363. ! &K4: Xon/Xoff handshake
  364. !
  365.   Write "AT&K4+FCLASS=1\r"
  366.   Jsr 100
  367.   Write "AT+VC=0\r"
  368.   Jsr 120
  369. !
  370. ! Now emit all commands that the application has sent to that port,
  371. ! except "FCLASS", etc
  372. !
  373.   EmitClear "+FCLASS","V","X","E","S0"
  374.   Jsr 60
  375.   Write "ATV0\r"
  376.   Jsr 110
  377. !
  378. ! Prepare to receive all error result codes, dial the number
  379. !
  380.   MatchClr
  381.   MatchStr 01 30 "1\r"
  382.   MatchStr 13 93 "3\r"
  383.   MatchStr 14 94 "8\r"
  384.   MatchStr 15 92 "7\r"
  385.   Write "ATD^1\r"
  386.   HsReset *
  387.   MatchRead 900
  388.   Write "\r"
  389.   Exit -6019
  390.  
  391. !
  392. ! Set the communication options:
  393. ! • \N0 &Q6: Normal connection (for ARA)
  394. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  395. ! • W1:  report connection speed
  396. !
  397. @Label 55
  398.   Write "AT\\N0&Q6&K3W1\r"
  399.   Jsr 100
  400.   return
  401.  
  402. !
  403. ! This section emits all modem commands sent from the client application
  404. ! For each set of commands the "OK" answer is awaited
  405. !
  406. @Label 60
  407.   EmitStart
  408. @Label 61
  409.   EmitCommand 62
  410.   Jsr 100
  411.   Jump 61
  412. @Label 62
  413.   return
  414. !
  415. ! This section initiates the modem before ANSWER and ORIGINATEs:
  416. ! extended responses + connect at the highest rate + speaker control +
  417. ! reset on Dtr drop + DCD valid
  418. ! Verbal responses mode, no echo
  419. !
  420. @Label 70
  421.   Write "ATX4N1M^2L^3^6&C1V1E0\r"
  422.   Jsr 100
  423.   return
  424.  
  425. !
  426. ! This section syncronize the modem after the serial port speed switching
  427. !
  428. @Label 80
  429.   ChrDelay 1
  430.   Write "\r\r"
  431.   Pause 2
  432.   Write "AT\r"
  433.   ChrDelay 0
  434.   Jsr 100
  435.   return
  436. !
  437. ! Prepare to receive error result codes, send the dialing command and
  438. ! set the user's handshake mode
  439. !
  440. @Label 90
  441.   MatchClr
  442.   MatchStr 2 91 "NO DIALTONE\r\n"
  443.   MatchStr 3 92 "BUSY\r\n"
  444.   MatchStr 4 93 "NO CARRIER\r\n"
  445.   MatchStr 5 94 "NO ANSWER\r\n"
  446.   Write "ATD^1\r"
  447.   HsReset *
  448.   return
  449.  
  450. @Label 91
  451.   exit -6020
  452. @Label 92
  453.   exit -6022
  454. @Label 93
  455.   exit -6021
  456. @Label 94
  457.   exit -6023
  458. !
  459. ! Processing the AT command:
  460. ! OK -> proceed
  461. ! ERROR or TimeOut ->exit -6019
  462. ! It can be called AFTER the "Write" command, since LineShare buffers input
  463. !
  464. @Label 100
  465.   MatchClr
  466.   MatchStr 1 103 "\r\nOK\r\n"
  467.   MatchStr 2 102 "\r\nERROR\r\n"
  468. @Label 101
  469.   MatchRead 20
  470. @Label 102
  471.   Exit -6019
  472. @Label 103
  473.   return
  474.  
  475. @Label 110
  476.   MatchClr
  477.   MatchStr 1 103 "0\r"
  478.   MatchStr 2 102 "4\r"
  479.   Jump 101
  480.  
  481. @Label 120
  482.   MatchClr
  483.   MatchStr 1 103 "\r\nOK\r\n"
  484.   MatchStr 2 103 "\r\nERROR\r\n"
  485.   MatchRead 20
  486.   Exit -6019
  487.  
  488. !This zeros out a location in memory that
  489. !when cleared, enables STF to send/receive faxes.
  490. @Label 130
  491.   MatchClr
  492.   Write "AT!2000M\r"
  493.   MatchStr 1 131 "\r\n2000: "
  494.   MatchRead 20
  495.   Jump 150
  496.  
  497. @Label 131
  498.   MatchClr
  499.   Write "00"
  500.   MatchStr 1 132 "\r\n2001: "
  501.   MatchRead20
  502.   Jump 150
  503.  
  504. @Label 132
  505.   MatchClr
  506.   Write "00"
  507.   MatchStr 1 133 "\r\n2002: "
  508.   MatchRead 20
  509.   Jump 150
  510.  
  511. @Label 133
  512.   MatchClr
  513.   Write "00"
  514.   MatchStr 1 134 "\r\n2003: "
  515.   MatchRead 20
  516.   Jump 150
  517.  
  518. @Label 134
  519.   MatchClr
  520.   Write "00"
  521.   MatchStr 1 135 "\r\n2004: "
  522.   MatchRead 20
  523.   Jump 150
  524.  
  525. @Label 135
  526.   MatchClr
  527.   Write " "
  528.   Jsr 100
  529.  
  530. @Label 136
  531.   MatchClr
  532.   Write "AT!2007M\r"
  533.   MatchStr 1 137 "\r\n2007: "
  534.   MatchRead 20
  535.   Jump 150
  536.  
  537. @Label 137
  538.   MatchClr
  539.   Write "00"
  540.   MatchStr 1 138 "\r\n2008: "
  541.   MatchRead20
  542.   Jump 150
  543.  
  544. @Label 138
  545.   MatchClr
  546.   Write "00"
  547.   MatchStr 1 139 "\r\n2009: "
  548.   MatchRead20
  549.   Jump 150
  550.  
  551. @Label 139
  552.   MatchClr
  553.   Write "00"
  554.   MatchStr 1 140 "\r\n200A: "
  555.   MatchRead20
  556.   Jump 150
  557.  
  558. @Label 140
  559.   MatchClr
  560.   Write "00"
  561.   MatchStr 1 141 "\r\n200B: "
  562.   MatchRead20
  563.   Jump 150
  564.  
  565. @Label 141
  566.   Write " "
  567.   Jsr 100
  568.   return
  569.  
  570. @Label 150
  571.   Note "Error clearing the modem's memory"
  572.   Pause 50
  573.   Write "   "
  574.   return
  575.  
  576. @Label 160
  577.   write "ATS0=0\r"
  578.   Jsr 100
  579.   Note "Voice, ARA, and Fax not running"
  580.   Pause 300
  581.   Jump 3
  582.